package com.demo.servlet.demo1217;

import javax.servlet.http.Cookie;

public class CookieUtils {
    //根据名称 找到相应的 Cookie
    public static Cookie findCookie(String name, Cookie[] cookies) {
        if (name == null || cookies == null || cookies.length == 0) {
            return null;
        }
        for (int i = 0; i < cookies.length; i++) {
            if (name.equals(cookies[i].getName())) {
                return cookies[i];
            }
        }
        return null;
    }
}
